package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderCustomerRibbonController {

    // cloud-provider-service 这个是项目的名称,表示访问的是cloud-provider-payment8001集群项目
    public static final String PAYMENY_URL = "http://cloud-provider-service";

    @Resource
    private RestTemplate restTemplate;

    @GetMapping(value ="ribbon/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id")Long id){
        log.info("进入查询");
        return restTemplate.getForObject(PAYMENY_URL + "/payment/get/" + id, CommonResult.class);
    }

}